package com.ebao.po.doctor;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.ebao.constants.Gender;
import com.ebao.po.user.TUserInfo;

/**
 * @desc 大夫
 * @author snow
 * @date 2012-6-28
 */
@Entity
@Table(name = "T_Doctor")
public class TDoctor implements Serializable {

	private static final long serialVersionUID = 4862490101260452121L;
	
	private String id;			// 主键UUID
	private String userName; 	// 用户名
	private String heads;		// 多个不同像素的头像,参照TUser中的头像说明
	private Gender sex; 		// 性别,女0,男1
	private Integer age; 		// 年龄
	private String password;	// 密码
	private String realName;	// 真实姓名
	private String email;		// 邮箱
	private String university;	// 大学
	private String education;	// 最高学历
	private String major;		// 专业
	private TUserInfo userInfo;	// 个人信息
	private THospital hospital; // 所属门诊/医院
	private Integer followNum;	// 关注数
	private Integer followedNum;// 被关注数
	private boolean isOnline = Boolean.FALSE;	// 是否在线
	private String lastLoginTime;//上次登录时间
	private Integer status = 0;		// 用户状态,0正常,1锁定
	private Integer seePatientState = 0;// 看病状态,0非空闲(不在线或忙碌),1空闲

	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Gender getSex() {
		return sex;
	}

	public void setSex(Gender sex) {
		this.sex = sex;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getHeads() {
		return heads;
	}

	public void setHeads(String heads) {
		this.heads = heads;
	}

	@Column(unique = true)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUniversity() {
		return university;
	}

	public void setUniversity(String university) {
		this.university = university;
	}

	public String getEducation() {
		return education;
	}

	public void setEducation(String education) {
		this.education = education;
	}

	public String getMajor() {
		return major;
	}

	public void setMajor(String major) {
		this.major = major;
	}

	public Integer getFollowNum() {
		return followNum;
	}

	public void setFollowNum(Integer followNum) {
		this.followNum = followNum;
	}

	public Integer getFollowedNum() {
		return followedNum;
	}

	public void setFollowedNum(Integer followedNum) {
		this.followedNum = followedNum;
	}

	public boolean isOnline() {
		return isOnline;
	}

	public void setOnline(boolean isOnline) {
		this.isOnline = isOnline;
	}

	@Column(length = 19)
	public String getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(String lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	@Column(length = 1)
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(length = 1)
	public Integer getSeePatientState() {
		return seePatientState;
	}

	public void setSeePatientState(Integer seePatientState) {
		this.seePatientState = seePatientState;
	}

	@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, optional = false, targetEntity = THospital.class)
	@JoinColumn(name = "hospital_id")
	public THospital getHospital() {
		return hospital;
	}

	public void setHospital(THospital hospital) {
		this.hospital = hospital;
	}

	@OneToOne(cascade = {CascadeType.ALL}, optional = false, targetEntity = TUserInfo.class)
	@JoinColumn(name = "userInfo_id")
	public TUserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(TUserInfo userInfo) {
		this.userInfo = userInfo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result + ((hospital == null) ? 0 : hospital.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((realName == null) ? 0 : realName.hashCode());
		result = prime * result + ((userInfo == null) ? 0 : userInfo.hashCode());
		result = prime * result + ((userName == null) ? 0 : userName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TDoctor other = (TDoctor) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (hospital == null) {
			if (other.hospital != null)
				return false;
		} else if (!hospital.equals(other.hospital))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (realName == null) {
			if (other.realName != null)
				return false;
		} else if (!realName.equals(other.realName))
			return false;
		if (userInfo == null) {
			if (other.userInfo != null)
				return false;
		} else if (!userInfo.equals(other.userInfo))
			return false;
		if (userName == null) {
			if (other.userName != null)
				return false;
		} else if (!userName.equals(other.userName))
			return false;
		return true;
	}

}
